﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Xml.Linq;
using Application = System.Windows.Forms.Application;
using UserControl = System.Windows.Controls.UserControl;

namespace Asteroids.Menu
{
    /// <summary>
    /// Interaction logic for Highscores.xaml
    /// </summary>
    public partial class Highscores : UserControl
    {
        private XDocument XDoc;

        public Highscores()
        {
            InitializeComponent();

            XDoc = XDocument.Load(Path.GetDirectoryName(Application.ExecutablePath) + "/Highscores.xml");
            DataContext = XDoc;

        }

        private void btnMainMenu_Click(object sender, RoutedEventArgs e)
        {
            MainWindow.Instance.HighscoresUC.Visibility = Visibility.Hidden;
            MainWindow.Instance.MainMenuUC.Visibility = Visibility.Visible;
        }

        private void btnExit_Click(object sender, RoutedEventArgs e)
        {
            Environment.Exit(0);
        }

        private void dtaHighscores_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            e.Row.Header = e.Row.GetIndex();
        }

        public void RefreshGrid()
        {
            DataContext = null;
            XDoc = XDocument.Load(Path.GetDirectoryName(Application.ExecutablePath) + "/Highscores.xml");
            DataContext = XDoc;
        }
    }
}
